package com.genesis.yunnanji.activity;

import android.os.Bundle;
import android.support.v7.widget.Toolbar;
import android.text.Editable;
import android.text.TextUtils;
import android.text.TextWatcher;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;

import com.genesis.yunnanji.R;

import org.xutils.view.annotation.ViewInject;

import es.dmoral.toasty.Toasty;



public class FeedBack extends BaseActivity {
    @ViewInject(R.id.tb_feedback_toolbar)
    private Toolbar mToolbar;
    @ViewInject(R.id.et_feedback_et)
    private EditText mEditText;
    @ViewInject(R.id.tv_feedback_textcount)
    private TextView tvCount;
    @ViewInject(R.id.bt_feedback_comfirm)
    private Button btConfirm;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState, R.layout.activity_feedback);
    }

    @Override
    protected void initView(Bundle savedInstanceState) {
        mToolbar.setTitle("");
        setSupportActionBar(mToolbar);
        getSupportActionBar().setDisplayHomeAsUpEnabled(true);
        mToolbar.setNavigationOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                finish();
            }
        });
    }

    @Override
    protected void setUpView() {
        mEditText.addTextChangedListener(new TextWatcher() {
            @Override
            public void beforeTextChanged(CharSequence s, int start, int count, int after) {

            }

            @Override
            public void onTextChanged(CharSequence s, int start, int before, int count) {

            }

            @Override
            public void afterTextChanged(Editable s) {
                tvCount.setText(s.length() + "");
            }
        });

        btConfirm.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                if (!TextUtils.isEmpty(mEditText.getText().toString())) {
                    mEditText.setText("");
                    Toasty.success(context, "提交成功，感谢您的反馈").show();
                    finish();
                } else {
                    Toasty.info(context, "请输入内容").show();
                }
            }
        });

    }
}
